package com.op.studyingliteapp.database.table;

import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

import com.op.studyingliteapp.BuildConfig;

/**
 * @author handsome
 * @version 创建时间：2015年7月25日 下午8:32:32 类说明
 */
public class ResourceTable implements BaseColumn {

	private static final String TAG = ResourceTable.class.getSimpleName();
	// Note table
	public static final String TABLE_COURSE_RESOURCE = "courseResource";
	public static final String COLUMN_TITLE = "title";
	public static final String COLUMN_COURSE_ID = "courseId";
	public static final String COLUMN_COURSE_NAME = "courseName";

	public static final String COLUMN_USER_ID = "userId";
	public static final String COLUMN_USER_NAME = "userName";
	public static final String COLUMN_USER_NUMBER = "userNumber";
	public static final String COLUMN_USER_PHONE = "userPhone";
	public static final String COLUMN_USER_EMAIL = "userEmail";
	public static final String COLUMN_USER_IS_USING = "userIsUsing";
	public static final String COLUMN_USER_TYPE = "userType";
	public static final String COLUMN_USER_IMAGE_URL = "userImageUrl";

	public static final String[] PROJECTION = { COLUMN_ID, COLUMN_TITLE, COLUMN_CREATE_TIME, COLUMN_UPDATE_TIME, COLUMN_COURSE_ID, COLUMN_USER_ID, COLUMN_USER_NAME, COLUMN_USER_NUMBER, COLUMN_USER_PHONE, COLUMN_USER_EMAIL, COLUMN_USER_IMAGE_URL, COLUMN_USER_IS_USING, COLUMN_USER_TYPE,
			COLUMN_COURSE_NAME };

	// Table creation SQL statement
	private static final String CREATE_TABLE = "create table " + TABLE_COURSE_RESOURCE + "(" + COLUMN_ID + " text primary key, " + COLUMN_TITLE + " text, " + COLUMN_CREATE_TIME + " text, " + COLUMN_UPDATE_TIME + " text, " + COLUMN_COURSE_ID + " text, " + COLUMN_USER_NAME + " text, "
			+ COLUMN_USER_NUMBER + " text, " + COLUMN_USER_PHONE + " text, " + COLUMN_COURSE_NAME + " text, " + COLUMN_USER_EMAIL + " text, " + COLUMN_USER_IMAGE_URL + " text, " + COLUMN_USER_ID + " text, " + COLUMN_USER_IS_USING + " text, " + COLUMN_USER_TYPE + " text" + ");";

	public static void onCreate(SQLiteDatabase db) {
		if (BuildConfig.DEBUG) {
			Log.i(TAG, "Creating course notification table");
		}
		db.execSQL(CREATE_TABLE);
	}

	public static void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		if (BuildConfig.DEBUG) {
			Log.i(TAG, "Upgrading course notification table");
		}
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_COURSE_RESOURCE);
		onCreate(db);
	}
}
